/**
 * create by young (young2f@outlook.com) on 2020/9/19
 */
'use strict';
import React, { Component } from 'react';
import { Input } from 'antd';

const { Search } = Input;

class SelectAndCreate extends Component {
  constructor(props) {
    super(props);
  }

  componentDidMount() {

  }


  onCreateClick = () => {
    const { createUrl, onCreateClick } = this.props;
    if (onCreateClick) {
      onCreateClick();
      return;
    }
    if (createUrl) {
      const w = window.open('about:blank');
      w.location.href = createUrl;
    }
  };

  render() {
    let { onSelectClick, enterButton, value,defaultValue, disabled, style } = this.props;

    let button = enterButton ? enterButton : '新增';
    return (
      <Search
        disabled={disabled}
        value={value}
        style={style}
        enterButton={button}
       // value={defaultValue}
        defaultValue={defaultValue}
        onClick={onSelectClick ? onSelectClick.bind(this) : undefined}
        onSearch={this.onCreateClick.bind(this)}></Search>
    );
  }
}

export default SelectAndCreate;
